version: '3.1'
services:
  stats-server:
    build: ./stat_svc/stat_server
    container_name: ewm-stat
    ports:
      - "9090:9090"
    depends_on:
      - stats-db
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://stats-db:5432/exploreWithMeStat?user=user&password=user

  stats-db:
    image: postgres:14-alpine
    container_name: stats-db
    ports:
      - "6543:5432"
    environment:
      - POSTGRES_DB=exploreWithMeStat
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=user

  ewm-service:
    build: main_svc
    container_name: ewm-main
    ports:
      - "8080:8080"
    depends_on:
      - ewm-db
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://ewm-db:5432/exploreWithMe?user=userdb&password=userdb
      - STAT_SERVER_URL=http://ewm-stat:9090

  ewm-db:
    image: postgres:14-alpine
    container_name: ewm-db
    ports:
      - "6542:5432"
    environment:
      - POSTGRES_DB=exploreWithMe
      - POSTGRES_USER=userdb
      - POSTGRES_PASSWORD=userdb